/*
 *    schedule.c  -  schedule api
 *
 *	  Board:		akae2440
 *    environment:	bootloader & ADS
 *    Author:		XingWenpeng
 *    Date:			2009-9-12
 *    web:			www.akaedu.org
 */

#include "task.h"
volatile unsigned int priority = 0;

extern int switch_to(struct task_struct *pcur,struct task_struct *pnext);			/*switch task*/
extern struct task_struct *current;
extern struct task_struct task[TASK_N];

int schedule(void)
{
	int next;
	struct task_struct *ptmp_task;
	
	next = ++priority % 3;					/*task call to order 0,1,2,0,1,2...*/
	
	ptmp_task = current;						/*exchange current task*/
	current = &task[next];
	
	switch_to(ptmp_task,current);		/*in the switch.s*/
	
	return 0;
}